import type { UserInfo, TaskInfo } from '../types/common';
import { TaskStatus } from '../types/common';
import type { PageResult } from '../types/api';

/**
 * 模拟用户数据
 */
export const mockUsers: UserInfo[] = [
  {
    id: '1',
    username: 'admin',
    nickname: '管理员',
    email: 'admin@tk-system.com',
    avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=admin',
    role: 'admin',
    createTime: '2024-01-01 10:00:00',
    updateTime: '2024-01-10 15:30:00',
  },
  {
    id: '2',
    username: 'zhangsan',
    nickname: '张三',
    email: 'zhangsan@tk-system.com',
    avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=zhangsan',
    role: 'user',
    createTime: '2024-01-02 09:15:00',
    updateTime: '2024-01-09 14:20:00',
  },
  {
    id: '3',
    username: 'lisi',
    nickname: '李四',
    email: 'lisi@tk-system.com',
    avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=lisi',
    role: 'user',
    createTime: '2024-01-03 11:30:00',
    updateTime: '2024-01-08 16:45:00',
  },
  {
    id: '4',
    username: 'wangwu',
    nickname: '王五',
    email: 'wangwu@tk-system.com',
    avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=wangwu',
    role: 'user',
    createTime: '2024-01-04 14:20:00',
    updateTime: '2024-01-07 10:15:00',
  },
  {
    id: '5',
    username: 'zhaoliu',
    nickname: '赵六',
    email: 'zhaoliu@tk-system.com',
    avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=zhaoliu',
    role: 'user',
    createTime: '2024-01-05 16:45:00',
    updateTime: '2024-01-06 13:30:00',
  },
];

/**
 * 模拟任务数据
 */
export const mockTasks: TaskInfo[] = [
  {
    id: '1',
    name: '用户界面设计',
    description: '设计系统的用户界面，包括登录页面、主页面和各个功能模块的界面',
    status: TaskStatus.PROGRESS,
    progress: 75,
    assignee: '张三',
    createTime: '2024-01-01 09:00:00',
    dueDate: '2024-01-15 18:00:00',
  },
  {
    id: '2',
    name: '后端API开发',
    description: '开发系统后端API接口，包括用户管理、任务管理等核心功能',
    status: TaskStatus.COMPLETED,
    progress: 100,
    assignee: '李四',
    createTime: '2024-01-02 10:30:00',
    dueDate: '2024-01-10 17:00:00',
  },
  {
    id: '3',
    name: '数据库优化',
    description: '优化数据库结构和查询性能，提升系统整体响应速度',
    status: TaskStatus.PENDING,
    progress: 30,
    assignee: '王五',
    createTime: '2024-01-03 14:15:00',
    dueDate: '2024-01-20 16:30:00',
  },
  {
    id: '4',
    name: '系统测试',
    description: '进行系统功能测试、性能测试和安全测试',
    status: TaskStatus.PROGRESS,
    progress: 45,
    assignee: '赵六',
    createTime: '2024-01-04 11:20:00',
    dueDate: '2024-01-18 15:45:00',
  },
  {
    id: '5',
    name: '文档编写',
    description: '编写系统使用文档、API文档和部署文档',
    status: TaskStatus.PENDING,
    progress: 10,
    assignee: '张三',
    createTime: '2024-01-05 13:45:00',
    dueDate: '2024-01-25 17:30:00',
  },
];

/**
 * 模拟系统统计数据
 */
export const mockSystemStats = {
  userCount: 11280,
  taskCount: 156,
  activeUsers: 9280,
  todayVisits: 1128,
};

/**
 * 模拟系统监控数据
 */
export const mockSystemMonitor = {
  cpu: 65,
  memory: 78,
  disk: 45,
  network: 32,
};

/**
 * 模拟系统信息
 */
export const mockSystemInfo = {
  version: 'v1.0.0',
  buildTime: '2024-01-01 12:00:00',
  environment: 'development',
};

/**
 * 生成分页数据的工具函数
 * @param data - 原始数据数组
 * @param current - 当前页码
 * @param pageSize - 每页条数
 * @returns 分页结果
 */
export const generatePageData = <T>(
  data: T[],
  current: number = 1,
  pageSize: number = 10
): PageResult<T> => {
  const startIndex = (current - 1) * pageSize;
  const endIndex = startIndex + pageSize;
  const list = data.slice(startIndex, endIndex);

  return {
    list,
    total: data.length,
    current,
    pageSize,
  };
};

/**
 * 默认导出所有mock数据
 */
const mockData = {
  users: mockUsers,
  tasks: mockTasks,
  systemStats: mockSystemStats,
  systemMonitor: mockSystemMonitor,
  systemInfo: mockSystemInfo,
  generatePageData,
};

export default mockData;